
<link href="/static/admin/eleme/element.css" rel="stylesheet" />
<link href="/static/admin/eleme/element-extends.css" rel="stylesheet" />

<section id="app" v-cloak>
  <el-row :gutter="20">
    <el-col :span="24">
      
<el-input v-model="name" placeholder="请输入机构名称" class="mt mb">
  <template slot="prepend">机构名称</template>
</el-input>

<el-input v-model="orcode" placeholder="请输入机构代码">
  <template slot="prepend">机构代码</template>
</el-input>

<el-date-picker
  class="mt mb"
  v-model="begintime"
  type="date"
  placeholder="连锁店开始计费日期"
  style="width: 100%">
</el-date-picker>

<el-date-picker
  class="mt mb"
  v-model="endtime"
  type="date"
  placeholder="连锁店到期截至日期"
  style="width: 100%">
</el-date-picker>

<el-input v-model="gnum" placeholder="请输入当前机构下允许新开分店数量" class="mt">
  <template slot="prepend">分店数量</template>
</el-input>

    </el-col>
  </el-row>
</section>

<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin/layer/layer.js"></script>
<script type="text/javascript" src="/static/admin/js/h.js"></script>
<script type="text/javascript" src="/static/admin/eleme/vue.js"></script>
<script type="text/javascript" src="/static/admin/eleme/element.js"></script>

<script>
var vm = new Vue({
  el: '#app',
  data: {
    {% for k, v in row %}
      {{ k }}: "{{ v }}",
    {% endfor %}
    begintime: '',
  },
  methods: {
    tips: function(msg){
      this.$message({
        message: msg,
        type: 'warning',
        showClose: true,
      })
    }
  }
})


function call_submit(index){

  if (vm.name == '') {
    vm.tips('请输入机构名称');
    return false;
  } else if (!/^\d{5,}$/.test(vm.orcode)) {
    vm.tips('请输入机构代码');
    return false;
  } else if (vm.begintime == '') {
    vm.tips('请选择机构开始运营时间');
    return false;
  } else if (vm.endtime == '') {
    vm.tips('请选择机构截至运营时间');
    return false;
  } else if (!/^[1-9]\d*$/.test(vm.gnum)) {
    vm.tips('请输入当前机构下允许新开分店数量');
    return false;
  }

  let info = {
    id: vm.id,
    name: vm.name,
    orcode: vm.orcode,
    begintime: Math.round(new Date(vm.begintime).valueOf()/1000),
    endtime: Math.round(new Date(vm.endtime).valueOf()/1000),
    gnum: vm.gnum
  }

  H.ajax('/admin/organization/editshop', info, 'post', function(res){
    parent.layer.msg(res.data, {icon:1, time:2000});
    parent.vm.getList();
    parent.layer.close(index);
  })
}
</script>